package ru.compscicenter.databases.zaikina.utils;

import ru.compscicenter.databases.zaikina.common.model.Node;
import ru.compscicenter.databases.zaikina.common.model.NodeConfig;
import ru.compscicenter.databases.zaikina.common.model.NodeType;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class ConstructConfigFile {
    public static void main(String[] args) throws IOException {
        final int startPort = 10000;
        ArrayList<Node> nodes = new ArrayList<Node>();
        nodes.add(Node.constructNode(0, NodeType.FileStorage, startPort));
        nodes.add(Node.constructNode(1, NodeType.HttpServer, 8080));
        for (int i = 2; i < 28; ++i) {
            nodes.add(Node.constructNode(i, NodeType.VocabularyNode, startPort + i));
        }
        NodeConfig config = new NodeConfig(nodes);
        BufferedWriter reader = null;
        reader = new BufferedWriter(new FileWriter("config.txt"));
        reader.write(config.toJSONString());
        reader.close();
    }
}
